package com.itheima.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {

    // 初识化方法 web服务器启动  创建filter实例调用 值执行一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
      log.info("init.....");
    }
    // 拦截到请求时调用 可以执行多次
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("doFilter.....");
    }
    // 销毁方法 , web服务器关闭是调用,只调用一次
    @Override
    public void destroy() {
        log.info("destroy.....");
    }
}
